<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">

<head>
<title>js第4课-03-获取一组元素-02-循环</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="这是js第4课-03-获取一组元素-02-循环">

<style type="text/css">
div {
	width: 200px;
	height: 200px;
	float: left;
	border: 1px solid black;
	margin: 10px;
}
</style>

<script>
	window.onload = function() {
		var aDiv = document.getElementsByTagName("div");
		for ( var k = 0; k < aDiv.length; k++) {
			aDiv[k].style.background = "yellow";
		}
	}
</script>

</head>

<body>
	<div></div>
	<div></div>
	<div></div>
	<div></div>
</body>

</html>